

package com.kclm.xsap.config;


import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;

import org.springframework.aop.interceptor.PerformanceMonitorInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@EnableTransactionManagement
@Configuration
@MapperScan("com.kclm.xsap.dao")
@Slf4j
public class MybatisPlusConfig {

    
    @Bean
    @Profile({"local","dev","pro"})  //设置 dev和pro环境开启
    public PerformanceMonitorInterceptor performanceMonitorInterceptor() {
        log.debug("创建SQL执行效率监视插件...");
        PerformanceMonitorInterceptor pmi = new PerformanceMonitorInterceptor();
        return pmi;
    }

    //注册乐观锁插件
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }



}
